home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / ADSP.h next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  10.3 KB  |  278 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        ADSP.h
  3.  
  4.      Contains:    AppleTalk Data Stream Protocol (ADSP) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1986-1993, 1995-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __ADSP__
  19. #define __ADSP__
  20.  
  21. #ifndef __ERRORS__
  22. #include <Errors.h>
  23. #endif
  24. #ifndef __APPLETALK__
  25. #include <AppleTalk.h>
  26. #endif
  27.  
  28.  
  29.  
  30. #if PRAGMA_ONCE
  31. #pragma once
  32. #endif
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37.  
  38. #if PRAGMA_IMPORT
  39. #pragma import on
  40. #endif
  41.  
  42. #if PRAGMA_STRUCT_ALIGN
  43.     #pragma options align=mac68k
  44. #elif PRAGMA_STRUCT_PACKPUSH
  45.     #pragma pack(push, 2)
  46. #elif PRAGMA_STRUCT_PACK
  47.     #pragma pack(2)
  48. #endif
  49.  
  50. /*driver control csCodes*/
  51.  
  52. enum {
  53.     dspInit                        = 255,                            /* create a new connection end */
  54.     dspRemove                    = 254,                            /* remove a connection end */
  55.     dspOpen                        = 253,                            /* open a connection */
  56.     dspClose                    = 252,                            /* close a connection */
  57.     dspCLInit                    = 251,                            /* create a connection listener */
  58.     dspCLRemove                    = 250,                            /* remove a connection listener */
  59.     dspCLListen                    = 249,                            /* post a listener request */
  60.     dspCLDeny                    = 248,                            /* deny an open connection request */
  61.     dspStatus                    = 247,                            /* get status of connection end */
  62.     dspRead                        = 246,                            /* read data from the connection */
  63.     dspWrite                    = 245,                            /* write data on the connection */
  64.     dspAttention                = 244,                            /* send an attention message */
  65.     dspOptions                    = 243,                            /* set connection end options */
  66.     dspReset                    = 242,                            /* forward reset the connection */
  67.     dspNewCID                    = 241                            /* generate a cid for a connection end */
  68. };
  69.  
  70.  
  71. enum {
  72.                                                                 /* connection opening modes */
  73.     ocRequest                    = 1,                            /* request a connection with remote */
  74.     ocPassive                    = 2,                            /* wait for a connection request from remote */
  75.     ocAccept                    = 3,                            /* accept request as delivered by listener */
  76.     ocEstablish                    = 4                                /* consider connection to be open */
  77. };
  78.  
  79.  
  80. enum {
  81.                                                                 /* connection end states */
  82.     sListening                    = 1,                            /* for connection listeners */
  83.     sPassive                    = 2,                            /* waiting for a connection request from remote */
  84.     sOpening                    = 3,                            /* requesting a connection with remote */
  85.     sOpen                        = 4,                            /* connection is open */
  86.     sClosing                    = 5,                            /* connection is being torn down */
  87.     sClosed                        = 6                                /* connection end state is closed */
  88. };
  89.  
  90.  
  91. enum {
  92.                                                                 /* client event flags */
  93.     eClosed                        = 0x80,                            /* received connection closed advice */
  94.     eTearDown                    = 0x40,                            /* connection closed due to broken connection */
  95.     eAttention                    = 0x20,                            /* received attention message */
  96.     eFwdReset                    = 0x10                            /* received forward reset advice */
  97. };
  98.  
  99.  
  100. enum {
  101.                                                                 /* miscellaneous constants */
  102.     attnBufSize                    = 570,                            /* size of client attention buffer */
  103.     minDSPQueueSize                = 100                            /* Minimum size of receive or send Queue */
  104. };
  105.  
  106. /* connection control block */
  107. typedef struct TRCCB                     TRCCB;
  108. typedef TRCCB *                            TPCCB;
  109. struct TRCCB {
  110.     TPCCB                             ccbLink;                    /* link to next ccb */
  111.     UInt16                             refNum;                        /* user reference number */
  112.     UInt16                             state;                        /* state of the connection end */
  113.     UInt8                             userFlags;                    /* flags for unsolicited connection events */
  114.     UInt8                             localSocket;                /* socket number of this connection end */
  115.     AddrBlock                         remoteAddress;                /* internet address of remote end */
  116.     UInt16                             attnCode;                    /* attention code received */
  117.     UInt16                             attnSize;                    /* size of received attention data */
  118.     void *                            attnPtr;                    /* ptr to received attention data */
  119.     UInt8                             reserved[220];                /* for adsp internal use */
  120. };
  121.  
  122. typedef CALLBACK_API( void , ADSPConnectionEventProcPtr )(TPCCB sourceCCB);
  123. /*
  124.     WARNING: ADSPConnectionEventProcPtr uses register based parameters under classic 68k
  125.              and cannot be written in a high-level language without 
  126.              the help of mixed mode or assembly glue.
  127. */
  128. typedef struct DSPParamBlock             DSPParamBlock;
  129. typedef DSPParamBlock *                    DSPPBPtr;
  130. typedef CALLBACK_API( void , ADSPCompletionProcPtr )(DSPPBPtr thePBPtr);
  131. /*
  132.     WARNING: ADSPCompletionProcPtr uses register based parameters under classic 68k
  133.              and cannot be written in a high-level language without 
  134.              the help of mixed mode or assembly glue.
  135. */
  136. typedef REGISTER_UPP_TYPE(ADSPConnectionEventProcPtr)             ADSPConnectionEventUPP;
  137. typedef REGISTER_UPP_TYPE(ADSPCompletionProcPtr)                 ADSPCompletionUPP;
  138. struct TRinitParams {
  139.     TPCCB                             ccbPtr;                        /* pointer to connection control block */
  140.     ADSPConnectionEventUPP             userRoutine;                /* client routine to call on event */
  141.     UInt16                             sendQSize;                    /* size of send queue (0..64K bytes) */
  142.     void *                            sendQueue;                    /* client passed send queue buffer */
  143.     UInt16                             recvQSize;                    /* size of receive queue (0..64K bytes) */
  144.     void *                            recvQueue;                    /* client passed receive queue buffer */
  145.     void *                            attnPtr;                    /* client passed receive attention buffer */
  146.     UInt8                             localSocket;                /* local socket number */
  147.     UInt8                             filler1;                    /* filler for proper byte alignment */
  148. };
  149. typedef struct TRinitParams TRinitParams;
  150.  
  151. struct TRopenParams {
  152.     UInt16                             localCID;                    /* local connection id */
  153.     UInt16                             remoteCID;                    /* remote connection id */
  154.     AddrBlock                         remoteAddress;                /* address of remote end */
  155.     AddrBlock                         filterAddress;                /* address filter */
  156.     UInt32                             sendSeq;                    /* local send sequence number */
  157.     UInt16                             sendWindow;                    /* send window size */
  158.     UInt32                             recvSeq;                    /* receive sequence number */
  159.     UInt32                             attnSendSeq;                /* attention send sequence number */
  160.     UInt32                             attnRecvSeq;                /* attention receive sequence number */
  161.     UInt8                             ocMode;                        /* open connection mode */
  162.     UInt8                             ocInterval;                    /* open connection request retry interval */
  163.     UInt8                             ocMaximum;                    /* open connection request retry maximum */
  164.     UInt8                             filler2;                    /* filler for proper byte alignment */
  165. };
  166. typedef struct TRopenParams TRopenParams;
  167.  
  168. struct TRcloseParams {
  169.     UInt8                             abort;                        /* abort connection immediately if non-zero */
  170.     UInt8                             filler3;                    /* filler for proper byte alignment */
  171. };
  172. typedef struct TRcloseParams TRcloseParams;
  173.  
  174. struct TRioParams {
  175.     UInt16                             reqCount;                    /* requested number of bytes */
  176.     UInt16                             actCount;                    /* actual number of bytes */
  177.     void *                            dataPtr;                    /* pointer to data buffer */
  178.     UInt8                             eom;                        /* indicates logical end of message */
  179.     UInt8                             flush;                        /* send data now */
  180. };
  181. typedef struct TRioParams TRioParams;
  182.  
  183. struct TRattnParams {
  184.     UInt16                             attnCode;                    /* client attention code */
  185.     UInt16                             attnSize;                    /* size of attention data */
  186.     void *                            attnData;                    /* pointer to attention data */
  187.     UInt8                             attnInterval;                /* retransmit timer in 10-tick intervals */
  188.     UInt8                             filler4;                    /* filler for proper byte alignment */
  189. };
  190. typedef struct TRattnParams TRattnParams;
  191.  
  192. struct TRstatusParams {
  193.     TPCCB                             statusCCB;                    /* pointer to ccb */
  194.     UInt16                             sendQPending;                /* pending bytes in send queue */
  195.     UInt16                             sendQFree;                    /* available buffer space in send queue */
  196.     UInt16                             recvQPending;                /* pending bytes in receive queue */
  197.     UInt16                             recvQFree;                    /* available buffer space in receive queue */
  198. };
  199. typedef struct TRstatusParams TRstatusParams;
  200.  
  201. struct TRoptionParams {
  202.     UInt16                             sendBlocking;                /* quantum for data packets */
  203.     UInt8                             sendTimer;                    /* send timer in 10-tick intervals */
  204.     UInt8                             rtmtTimer;                    /* retransmit timer in 10-tick intervals */
  205.     UInt8                             badSeqMax;                    /* threshold for sending retransmit advice */
  206.     UInt8                             useCheckSum;                /* use ddp packet checksum */
  207. };
  208. typedef struct TRoptionParams TRoptionParams;
  209.  
  210. struct TRnewcidParams {
  211.     UInt16                             newcid;                        /* new connection id returned */
  212. };
  213. typedef struct TRnewcidParams TRnewcidParams;
  214.  
  215. struct DSPParamBlock {
  216.     QElem *                            qLink;
  217.     short                             qType;
  218.     short                             ioTrap;
  219.     Ptr                             ioCmdAddr;
  220.     ADSPCompletionUPP                 ioCompletion;
  221.     OSErr                             ioResult;
  222.     StringPtr                         ioNamePtr;
  223.     short                             ioVRefNum;
  224.     short                             ioCRefNum;                    /* adsp driver refNum */
  225.     short                             csCode;                        /* adsp driver control code */
  226.     long                             qStatus;                    /* adsp internal use */
  227.     short                             ccbRefNum;
  228.     union {
  229.         TRinitParams                     initParams;
  230.         TRopenParams                     openParams;
  231.         TRcloseParams                     closeParams;            /*dspClose, dspRemove*/
  232.         TRioParams                         ioParams;                /*dspRead, dspWrite*/
  233.         TRattnParams                     attnParams;                /*dspAttention*/
  234.         TRstatusParams                     statusParams;            /*dspStatus*/
  235.         TRoptionParams                     optionParams;            /*dspOptions*/
  236.         TRnewcidParams                     newCIDParams;            /*dspNewCID*/
  237.     }                                 u;
  238. };
  239.  
  240. enum { uppADSPConnectionEventProcInfo = 0x0000B802 };             /* register no_return_value Func(4_bytes:A1) */
  241. enum { uppADSPCompletionProcInfo = 0x00009802 };                 /* register no_return_value Func(4_bytes:A0) */
  242. #define NewADSPConnectionEventProc(userRoutine)                 (ADSPConnectionEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPConnectionEventProcInfo, GetCurrentArchitecture())
  243. #define NewADSPCompletionProc(userRoutine)                         (ADSPCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPCompletionProcInfo, GetCurrentArchitecture())
  244. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  245.     #pragma parameter CallADSPConnectionEventProc(__A0, __A1)
  246.     void CallADSPConnectionEventProc(ADSPConnectionEventUPP routine, TPCCB sourceCCB) = 0x4E90;
  247. #else
  248.     #define CallADSPConnectionEventProc(userRoutine, sourceCCB)  CALL_ONE_PARAMETER_UPP((userRoutine), uppADSPConnectionEventProcInfo, (sourceCCB))
  249. #endif
  250. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  251.     #pragma parameter CallADSPCompletionProc(__A1, __A0)
  252.     void CallADSPCompletionProc(ADSPCompletionUPP routine, DSPPBPtr thePBPtr) = 0x4E91;
  253. #else
  254.     #define CallADSPCompletionProc(userRoutine, thePBPtr)         CALL_ONE_PARAMETER_UPP((userRoutine), uppADSPCompletionProcInfo, (thePBPtr))
  255. #endif
  256.  
  257.  
  258. #if PRAGMA_STRUCT_ALIGN
  259.     #pragma options align=reset
  260. #elif PRAGMA_STRUCT_PACKPUSH
  261.     #pragma pack(pop)
  262. #elif PRAGMA_STRUCT_PACK
  263.     #pragma pack()
  264. #endif
  265.  
  266. #ifdef PRAGMA_IMPORT_OFF
  267. #pragma import off
  268. #elif PRAGMA_IMPORT
  269. #pragma import reset
  270. #endif
  271.  
  272. #ifdef __cplusplus
  273. }
  274. #endif
  275.  
  276. #endif /* __ADSP__ */
  277.  
  278.